export default {
    set(key, value) {
        let v = null;
        if (typeof value === 'object') {
            try {
                v = JSON.stringify({type: 'object', data: value});
            } catch (e) {
                console.log(v);
            }
        } else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
            v = JSON.stringify({type: 'string', data: value});
        }
        localStorage.setItem(key, v);
    },
    get(key) {
        let v = localStorage.getItem(key);
        try {
            let json = JSON.parse(v);
            return json.data;
        } catch (e) {
            return null;
        }

    },
    remove(key) {
        localStorage.removeItem(key);
    }
};
